<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script th:src="@{/layer/JQuery/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/layer/layer/layer.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <script th:src="@{/layui/layui.js}"></script>

    <style>
        .layui-input-block {
            margin-right: 200px;
        }
    </style>

</head>

<body>
<form class="layui-form" th:action="@{/teacher}" method="post">
    <input type="hidden" name="_method" value="put"/>
    <input type="hidden" name="tid" th:value="${teacher.tid}">

    <div class="layui-form-item" style="margin-top: 10px">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="tname" th:value="${teacher.tname}" lay-verify="required" autocomplete="off"
                   class="layui-input" maxlength="8" minlength="8">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属类别</label>
        <div class="layui-input-block">
            <select name="ttid" lay-verify="required">
                <option th:text="${teacher.talentName}" th:value="${teacher.ttid}"></option>
                <option th:each="talent:${talentList}" th:text="${talent.tname}"
                        th:value="${talent.ttid}"></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">照片</label>
        <img th:src="${teacher.tphoto}" style="width: 120px; height: 160px">
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">信息来源</label>
        <div class="layui-input-block">
            <input type="text" name="tsource" autocomplete="off"
                   class="layui-input" th:value="${teacher.tsource}">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">个人简介</label>
        <div class="layui-input-block">
            <textarea id="edit" th:text="${teacher.tintro}" name="tintro" style="display: none;" class="field-content"
                      lay-verify="content"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" id="modifybutton" lay-submit="" lay-filter="demo">修改</button>
            <a th:href="@{/teachers/1}">
                <input type="button" class="layui-btn layui-btn-primary" value="返回" style="margin-left: 9px;"></input>
            </a>
        </div>
    </div>

</form>

<script>
    layui.use('form', function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });

    layui.use(['layer','layedit','form','jquery'], function () {
        var form = layui.form, layer = layui.layer;
        var $ = layui.$;
        var layedit = layui.layedit;
        var index = layedit.build('edit', {width: 400}); //建立编辑器
        form.verify({
            content: function (value) {
                return layedit.sync(index);
            }
        });
    });
</script>
</body>

</html>